package com.the_last.utils;

import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author zhanghaifeng
 */
@Component
@Slf4j
public class EnvironmentUtil {
    
    private static String ENVIRONMENT;
    @Value("${spring.profiles.active}")
    private String active;
    
    private EnvironmentUtil() {
    }
    
    /**
     * 是否处于生产环境
     *
     * @return true or false
     */
    public static boolean isPro() {
        return ENVIRONMENT.contains("pro");
    }
    
    /**
     * 是否处于开发环境
     *
     * @return true or false
     */
    public static boolean isDev() {
        return ENVIRONMENT.contains("dev");
    }
    
    @PostConstruct
    private void init() {
        ENVIRONMENT = active;
        log.info(ENVIRONMENT);
    }
    
}
